package at.jku.ase.communication;

import at.jku.ase.encryption.Keys;
import at.jku.ase.utils.CryptUtils;

import javax.crypto.SecretKey;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.util.UUID;

/**
 * Created by IntelliJ IDEA.
 * User: stellit
 * Date: 12/16/11
 * Time: 9:43 AM
 * To change this template use File | Settings | File Templates.
 */
public class SessionObject {

    private String id;
    private PublicKey receiverPublicKey;
    private PublicKey myPublicKey;
    private PrivateKey myPrivateKey;
    private SecretKey secretKey;
    private byte[] data;
    private byte[] signature;
    private boolean signStatus;

    private SessionObject(Keys<PublicKey, PrivateKey> keys) {
        this.myPublicKey = keys.getPublicKey();
        this.myPrivateKey = keys.getPrivateKey();
        this.id = UUID.randomUUID().toString();
    }

    public static SessionObject newInstance() {
        return new SessionObject(CryptUtils.generateRSAKeyPair());
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public PublicKey getReceiverPublicKey() {
        return receiverPublicKey;
    }

    public void setReceiverPublicKey(PublicKey receiverPublicKey) {
        this.receiverPublicKey = receiverPublicKey;
    }

    public PublicKey getMyPublicKey() {
        return myPublicKey;
    }

    public PrivateKey getMyPrivateKey() {
        return myPrivateKey;
    }

    public SecretKey getSecretKey() {
        return secretKey;
    }

    public void setSecretKey(SecretKey secretKey) {
        this.secretKey = secretKey;
    }

    public byte[] getData() {
        return data;
    }

    public void setData(byte[] data) {
        this.data = data;
    }

    public byte[] getSignature() {
        return signature;
    }

    public void setSignature(byte[] signature) {
        this.signature = signature;
    }

    public boolean isSignValid() {
        return signStatus;
    }

    public void setSignStatus(boolean signStatus) {
        this.signStatus = signStatus;
    }

}
